home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / Cookie / last-visit.izs < prev    next >
Text File  |  2005-09-28  |  7KB  |  247 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>Name - Visits - Last Visit
  4. <!/TITLE>
  5.  
  6. <!DESCRIPTION>This script stores the users name, how many times he or she has visited and the date when they last visited!<!/DESCRIPTION> 
  7.  
  8. <!CATEGORY>cookies<!/CATEGORY>
  9.  
  10. <!SCRIPT>
  11. <!-- START OF SCRIPT -->
  12.  
  13. <!-- HOW TO INSTALL COOKIE:  NAME - VISITS - LAST VISIT:
  14.  
  15.    1.  Put the designated script into the HEAD of your HTML document
  16.    2.  Copy the last script into the BODY of your HTML document  -->
  17.  
  18. <!-- STEP ONE: Copy this code into the HEAD of your HTML document  -->
  19.           
  20. <HEAD>
  21.  
  22. <SCRIPT LANGUAGE="JavaScript">
  23. <!-- Original:  Mattias Sjoberg -->
  24.  
  25.  
  26. <!-- Begin
  27. var expDays = 30;
  28. var exp = new Date(); 
  29. exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
  30. function Who(info){
  31. var VisitorName = GetCookie('VisitorName')
  32. if (VisitorName == null) {
  33. VisitorName = prompt("Who are you?");
  34. SetCookie ('VisitorName', VisitorName, exp);
  35. }
  36. return VisitorName;
  37. }
  38. function When(info){
  39. var rightNow = new Date()
  40. var WWHTime = 0;
  41. WWHTime = GetCookie('WWhenH')
  42. WWHTime = WWHTime * 1
  43. var lastHereFormatting = new Date(WWHTime);
  44. var intLastVisit = (lastHereFormatting.getYear() * 10000)+(lastHereFormatting.getMonth() * 100) + lastHereFormatting.getDate()
  45. var lastHereInDateFormat = "" + lastHereFormatting;
  46. var dayOfWeek = lastHereInDateFormat.substring(0,3)
  47. var dateMonth = lastHereInDateFormat.substring(4,11)
  48. var timeOfDay = lastHereInDateFormat.substring(11,16)
  49. var year = lastHereInDateFormat.substring(23,25)
  50. var WWHText = dayOfWeek + ", " + dateMonth + " at " + timeOfDay
  51. SetCookie ("WWhenH", rightNow.getTime(), exp)
  52. return WWHText
  53. }
  54. function Count(info){
  55. var WWHCount = GetCookie('WWHCount')
  56. if (WWHCount == null) {
  57. WWHCount = 0;
  58. }
  59. else{
  60. WWHCount++;
  61. }
  62. SetCookie ('WWHCount', WWHCount, exp);
  63. return WWHCount;
  64. }
  65. function set(){
  66. VisitorName = prompt("Who are you?");
  67. SetCookie ('VisitorName', VisitorName, exp);
  68. SetCookie ('WWHCount', 0, exp);
  69. SetCookie ('WWhenH', 0, exp);
  70. }
  71. function getCookieVal (offset) {  
  72. var endstr = document.cookie.indexOf (";", offset);  
  73. if (endstr == -1)    
  74. endstr = document.cookie.length;  
  75. return unescape(document.cookie.substring(offset, endstr));
  76. }
  77. function GetCookie (name) {  
  78. var arg = name + "=";  
  79. var alen = arg.length;  
  80. var clen = document.cookie.length;  
  81. var i = 0;  
  82. while (i < clen) {    
  83. var j = i + alen;    
  84. if (document.cookie.substring(i, j) == arg)      
  85. return getCookieVal (j);    
  86. i = document.cookie.indexOf(" ", i) + 1;    
  87. if (i == 0) break;   
  88. }  
  89. return null;
  90. }
  91. function SetCookie (name, value) {  
  92. var argv = SetCookie.arguments;  
  93. var argc = SetCookie.arguments.length;  
  94. var expires = (argc > 2) ? argv[2] : null;  
  95. var path = (argc > 3) ? argv[3] : null;  
  96. var domain = (argc > 4) ? argv[4] : null;  
  97. var secure = (argc > 5) ? argv[5] : false;  
  98. document.cookie = name + "=" + escape (value) + 
  99. ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
  100. ((path == null) ? "" : ("; path=" + path)) +  
  101. ((domain == null) ? "" : ("; domain=" + domain)) +    
  102. ((secure == true) ? "; secure" : "");
  103. }
  104. function DeleteCookie (name) {  
  105. var exp = new Date();  
  106. exp.setTime (exp.getTime() - 1);  
  107. var cval = GetCookie (name);  
  108. document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
  109. }
  110. //  End -->
  111. </SCRIPT>
  112.  
  113. <!-- STEP TWO: Add code into BODY section of document  -->
  114.  
  115. <BODY>
  116.  
  117. <CENTER>
  118. <SCRIPT LANGUAGE="JavaScript">
  119. document.write("Hello " + Who() + ". You've been here " + Count() + " time(s).  Last time was " + When() +".");
  120. </SCRIPT>
  121. </CENTER>
  122.  
  123.  
  124. <!-- END OF SCRIPT -->
  125. <!/SCRIPT>
  126.  
  127. <!PREVIEW>
  128. <!-- START OF SCRIPT -->
  129.  
  130.  
  131. <!-- HOW TO INSTALL COOKIE:  NAME - VISITS - LAST VISIT:
  132.  
  133.    1.  Put the designated script into the HEAD of your HTML document
  134.    2.  Copy the last script into the BODY of your HTML document  -->
  135.  
  136. <!-- STEP ONE: Copy this code into the HEAD of your HTML document  -->
  137.           
  138. <HEAD>
  139.  
  140. <SCRIPT LANGUAGE="JavaScript">
  141. <!-- Original:  Mattias Sjoberg -->
  142.  
  143.  
  144. <!-- Begin
  145. var expDays = 30;
  146. var exp = new Date(); 
  147. exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
  148. function Who(info){
  149. var VisitorName = GetCookie('VisitorName')
  150. if (VisitorName == null) {
  151. VisitorName = prompt("Who are you?");
  152. SetCookie ('VisitorName', VisitorName, exp);
  153. }
  154. return VisitorName;
  155. }
  156. function When(info){
  157. var rightNow = new Date()
  158. var WWHTime = 0;
  159. WWHTime = GetCookie('WWhenH')
  160. WWHTime = WWHTime * 1
  161. var lastHereFormatting = new Date(WWHTime);
  162. var intLastVisit = (lastHereFormatting.getYear() * 10000)+(lastHereFormatting.getMonth() * 100) + lastHereFormatting.getDate()
  163. var lastHereInDateFormat = "" + lastHereFormatting;
  164. var dayOfWeek = lastHereInDateFormat.substring(0,3)
  165. var dateMonth = lastHereInDateFormat.substring(4,11)
  166. var timeOfDay = lastHereInDateFormat.substring(11,16)
  167. var year = lastHereInDateFormat.substring(23,25)
  168. var WWHText = dayOfWeek + ", " + dateMonth + " at " + timeOfDay
  169. SetCookie ("WWhenH", rightNow.getTime(), exp)
  170. return WWHText
  171. }
  172. function Count(info){
  173. var WWHCount = GetCookie('WWHCount')
  174. if (WWHCount == null) {
  175. WWHCount = 0;
  176. }
  177. else{
  178. WWHCount++;
  179. }
  180. SetCookie ('WWHCount', WWHCount, exp);
  181. return WWHCount;
  182. }
  183. function set(){
  184. VisitorName = prompt("Who are you?");
  185. SetCookie ('VisitorName', VisitorName, exp);
  186. SetCookie ('WWHCount', 0, exp);
  187. SetCookie ('WWhenH', 0, exp);
  188. }
  189. function getCookieVal (offset) {  
  190. var endstr = document.cookie.indexOf (";", offset);  
  191. if (endstr == -1)    
  192. endstr = document.cookie.length;  
  193. return unescape(document.cookie.substring(offset, endstr));
  194. }
  195. function GetCookie (name) {  
  196. var arg = name + "=";  
  197. var alen = arg.length;  
  198. var clen = document.cookie.length;  
  199. var i = 0;  
  200. while (i < clen) {    
  201. var j = i + alen;    
  202. if (document.cookie.substring(i, j) == arg)      
  203. return getCookieVal (j);    
  204. i = document.cookie.indexOf(" ", i) + 1;    
  205. if (i == 0) break;   
  206. }  
  207. return null;
  208. }
  209. function SetCookie (name, value) {  
  210. var argv = SetCookie.arguments;  
  211. var argc = SetCookie.arguments.length;  
  212. var expires = (argc > 2) ? argv[2] : null;  
  213. var path = (argc > 3) ? argv[3] : null;  
  214. var domain = (argc > 4) ? argv[4] : null;  
  215. var secure = (argc > 5) ? argv[5] : false;  
  216. document.cookie = name + "=" + escape (value) + 
  217. ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
  218. ((path == null) ? "" : ("; path=" + path)) +  
  219. ((domain == null) ? "" : ("; domain=" + domain)) +    
  220. ((secure == true) ? "; secure" : "");
  221. }
  222. function DeleteCookie (name) {  
  223. var exp = new Date();  
  224. exp.setTime (exp.getTime() - 1);  
  225. var cval = GetCookie (name);  
  226. document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
  227. }
  228. //  End -->
  229. </SCRIPT>
  230.  
  231. <!-- STEP TWO: Add code into BODY section of document  -->
  232.  
  233. <BODY>
  234.  
  235. <CENTER>
  236. <SCRIPT LANGUAGE="JavaScript">
  237. document.write("Hello " + Who() + ". You've been here " + Count() + " time(s).  Last time was " + When() +".");
  238. </SCRIPT>
  239. </CENTER>
  240.  
  241.  
  242.  
  243. <!-- END OF SCRIPT -->
  244. <!/PREVIEW>
  245.  
  246. <!RELATED>NONE<!/RELATED>
  247.